#import "MobilePong.h"
#import "PongMainView.h"
#import "ShellKeyboard.h"

@implementation MobilePong

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {

	struct CGRect rect	=	[UIHardware fullScreenApplicationContentRect];
	rect.origin.x		=	rect.origin.y = 0.0f;

	//Basically a background
	_window = [[UIWindow alloc] initWithContentRect:rect];	

	//This is actually the controller of the application, in large part.
	startView			=	[[PongMainView alloc] initWithFrame: rect];
		
	[_window	setContentView:	startView]; 
	[_window	orderFront:		self];
	[_window	makeKey:		self];
	[_window	_setHidden:		NO];
}

- (void)applicationWillTerminate {
	[_window release];
}

- (void)applicationWillSuspend
{
	//Pause game here (invalidate timer)
	LogMethod();
}

- (void)applicationDidResume
{
	//Restart game here (kick in the timer)
	LogMethod();
}

- (void)applicationResume:(struct __GSEvent *)fp8;	// IMP=0x323b2d7c
{
	//Probably do nothing; applicationDidResume will probably be sufficient
	LogMethod();
}

- (void)deviceOrientationChanged:(struct __GSEvent *)fp8;
{
	
	/*
	http://www.dshadow.com/software/patches/MobileTerminalEvents-001-r90.patch
    UIHardware + (int)deviceOrientation:(BOOL)fp8
	deviceOrientation returns the orientation of the iPhone.
	1	normal
	2	upside down
	3	horizontal - turned left
	4	horizontal - turned right
	*/
	
	//LogMethod();
	[startView deviceOrientationChanged:fp8];
}


@end
